#!/usr/bin/python
#coding:utf8

"""
Chain of Responsibility
"""
class Handler:
    def __init__(self):
        self.successor = None
    def setSuccessor(self, successor):
        self.successor = successor

class ConcreteHandler(Handler):
    def __init__(self,role,day=0):
        self.day = day
        self.role = role
    def handle(self, request):
        if 0 < request <= self.day:
            print(f"{self.role}审批成功，批假{request}天")
        else:
            self.successor.handle(request)


if __name__ == "__main__":
    requests = [3,7,30]
    class_teacher = ConcreteHandler("班主任",3)
    counsellor = ConcreteHandler("学工处",14)
    vice_principal = ConcreteHandler("校办",365)
    class_teacher.setSuccessor(counsellor)
    counsellor.setSuccessor(vice_principal)
    for request in requests:
        class_teacher.handle(request)